<?php

namespace app\admin\model\hf;

use think\Model;


class Qdorder extends Model
{

    

    

    // 表名
    protected $name = 'hf_order';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'statuss_text',
        'yys_text',
        'cztype_text',
        'refundtime_text',
        'update_time_text',
        'from_text'
    ];
    

    
    public function getStatussList()
    {
        return ['1' => __('Statuss 1'), '2' => __('Statuss 2'), '3' => __('Statuss 3'), '4' => __('Statuss 4'), '5' => __('Statuss 5')];
    }

    public function getYysList()
    {
        return ['0' => __('Yys 0'), '1' => __('Yys 1'), '2' => __('Yys 2'), '3' => __('Yys 3'), '4' => __('Yys 4'), '5' => __('Yys 5'), '6' => __('Yys 6'), '7' => __('Yys 7')];
    }

    public function getCztypeList()
    {
        return ['1' => __('Cztype 1'), '2' => __('Cztype 2')];
    }

    public function getFromList()
    {
        return ['1' => __('From 1'), '2' => __('From 2')];
    }


    public function getStatussTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['statuss']) ? $data['statuss'] : '');
        $list = $this->getStatussList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getYysTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['yys']) ? $data['yys'] : '');
        $list = $this->getYysList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCztypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['cztype']) ? $data['cztype'] : '');
        $list = $this->getCztypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getRefundtimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['refundtime']) ? $data['refundtime'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getFromTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['from']) ? $data['from'] : '');
        $list = $this->getFromList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    protected function setRefundtimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setUpdateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
